/*jslint browser: true, cap: false, passfail: false, undef: false, white: false */
/*global SONGHAY YAHOO */

(function(){

    //Module-level members:
    var application = SONGHAY.ui.GenericWebEditor;
    var client = SONGHAY.ui.Client;
    var clickHandler = SONGHAY.ui.GenericWebEditor.clickHandler;
    var xmlHelper = SONGHAY.ui.GenericWebEditor.xmlHelper;

    SONGHAY.ui.Events =
    {
        //Events by Metadata ID:
        CheckBox: { eventType: 'click', eventCallback: client.dataForm.inputIsCheck, eventPassThroughObject: null },
        DocumentLink: { eventType: 'click', eventCallback: client.ajax.getAndDisplay, eventPassThroughObject: { serverCommand: 'GetDocumentForEdit'} },
        DocumentLink_Inactive: { eventType: 'click', eventCallback: client.ajax.getAndDisplay, eventPassThroughObject: { serverCommand: 'GetDocumentForEdit'} },
        FragmentLink: { eventType: 'click', eventCallback: client.ajax.getAndDisplay, eventPassThroughObject: { serverCommand: 'GetFragmentForEdit'} },
        ParentSegmentIdUlDropDownItems: { eventType: 'click', eventCallback: clickHandler.ulDropDownItemClick, eventPassThroughObject: { targetId: 'ParentSegmentId'} },
        SearchResultForDocument: { eventType: 'click', eventCallback: client.ajax.getAndDisplay, eventPassThroughObject: { serverCommand: 'GetDocumentForEdit'} },
        SearchResultForFragment: { eventType: 'click', eventCallback: client.ajax.getAndDisplay, eventPassThroughObject: { serverCommand: 'GetFragmentForEdit'} },
        SearchResultForSegment: { eventType: 'click', eventCallback: client.ajax.getAndDisplay, eventPassThroughObject: { serverCommand: 'GetSegmentForEdit'} },
        SegmentIdUlDropDownItems: { eventType: 'click', eventCallback: clickHandler.ulDropDownItemClick, eventPassThroughObject: { targetId: 'SegmentId'} },
        SegmentLink: { eventType: 'click', eventCallback: client.ajax.getAndDisplay, eventPassThroughObject: { serverCommand: 'GetSegmentForEdit'} },
        SegmentLink_Inactive: { eventType: 'click', eventCallback: client.ajax.getAndDisplay, eventPassThroughObject: { serverCommand: 'GetSegmentForEdit'} },
        WebIndexTog: { eventType: 'click', eventCallback: clickHandler.toggleIndexBlog, eventPassThroughObject: null },

        //Events by Widget ID:
        CreateDate: { eventType: 'click', eventCallback: clickHandler.calendarShow, eventPassThroughObject: { sourceId: 'CreateDate', targetId: 'CreateDateText'} },
        ChangeDataSource: { eventType: 'click', eventCallback: function() { window.location.href = './'; }, eventPassThroughObject: null },
        DeleteDocument: { eventType: 'click', eventCallback: client.dataForm.confirm, eventPassThroughObject: { xmlGetter: xmlHelper.getDocumentXmlString, serverCommand: 'DeleteDocument'} },
        DeleteFragment: { eventType: 'click', eventCallback: client.dataForm.confirm, eventPassThroughObject: { xmlGetter: xmlHelper.getFragmentXmlString, serverCommand: 'DeleteFragment'} },
        DeleteSegment: { eventType: 'click', eventCallback: client.dataForm.confirm, eventPassThroughObject: { xmlGetter: xmlHelper.getSegmentXmlString, serverCommand: 'DeleteSegment'} },
        EndDate: { eventType: 'click', eventCallback: clickHandler.calendarShow, eventPassThroughObject: { sourceId: 'EndDate', targetId: 'EndDateText'} },
        Index: { eventType: 'click', eventCallback: client.ajax.display, eventPassThroughObject: { serverCommand: 'ListGenericWebIndexForEdit'} },
        ModificationDate: { eventType: 'click', eventCallback: clickHandler.calendarShow, eventPassThroughObject: { sourceId: 'ModificationDate', targetId: 'ModificationDateText'} },
        NewDocument: { eventType: 'click', eventCallback: client.ajax.display, eventPassThroughObject: { serverCommand: 'NewDocument'} },
        NewFragment: { eventType: 'click', eventCallback: client.ajax.display, eventPassThroughObject: { serverCommand: 'NewFragment'} },
        NewSegment: { eventType: 'click', eventCallback: client.ajax.display, eventPassThroughObject: { serverCommand: 'NewSegment'} },
        ParentSegmentIdRemove: { eventType: 'click', eventCallback: clickHandler.ulDropDownRemoveClick, eventPassThroughObject: { targetId: 'ParentSegmentId'} },
        ParentSegmentIdCancel: { eventType: 'click', eventCallback: clickHandler.ulDropDownCancelClick, eventPassThroughObject: { targetId: 'ParentSegmentIdItemsBlock'} },
        ParentSegmentIdReset: { eventType: 'click', eventCallback: clickHandler.ulDropDownResetClick, eventPassThroughObject: { targetId: 'ParentSegmentId'} },
        ParentSegmentIdSelectedItem: { eventType: 'click', eventCallback: clickHandler.ulDropDownClick, eventPassThroughObject: { targetId: 'ParentSegmentId'} },
        SaveDocument: { eventType: 'click', eventCallback: client.ajax.postAndDisplay, eventPassThroughObject: { xmlGetter: xmlHelper.getDocumentXmlString, serverCommand: 'SetDocument'} },
        SaveNewDocument: { eventType: 'click', eventCallback: client.ajax.postAndDisplay, eventPassThroughObject: { xmlGetter: xmlHelper.getDocumentXmlString, serverCommand: 'InsertDocument'} },
        SaveFragment: { eventType: 'click', eventCallback: client.ajax.postAndDisplay, eventPassThroughObject: { xmlGetter: xmlHelper.getFragmentXmlString, serverCommand: 'SetFragment'} },
        SaveNewFragment: { eventType: 'click', eventCallback: client.ajax.postAndDisplay, eventPassThroughObject: { xmlGetter: xmlHelper.getFragmentXmlString, serverCommand: 'InsertFragment'} },
        SaveSegment: { eventType: 'click', eventCallback: client.ajax.postAndDisplay, eventPassThroughObject: { xmlGetter: xmlHelper.getSegmentXmlString, serverCommand: 'SetSegment'} },
        SaveNewSegment: { eventType: 'click', eventCallback: client.ajax.postAndDisplay, eventPassThroughObject: { xmlGetter: xmlHelper.getSegmentXmlString, serverCommand: 'InsertSegment'} },
        Search: { eventType: 'click', eventCallback: client.ajax.postAndDisplay, eventPassThroughObject: { xmlGetter: xmlHelper.getSearchXmlString, serverCommand: 'Search'} },
        SearchResultsNextRows: { eventType: 'click', eventCallback: clickHandler.searchPageForward, eventPassThroughObject: null },
        SearchResultsPreviousRows: { eventType: 'click', eventCallback: clickHandler.searchPageBack, eventPassThroughObject: null },
        SearchText: [{ eventType: 'blur', eventCallback: application.searchTextBlur, eventPassThroughObject: null }, { eventType: 'focus', eventCallback: application.searchTextFocus, eventPassThroughObject: null}],
        SegmentIdCancel: { eventType: 'click', eventCallback: clickHandler.ulDropDownCancelClick, eventPassThroughObject: { targetId: 'SegmentIdItemsBlock'} },
        SegmentIdReset: { eventType: 'click', eventCallback: clickHandler.ulDropDownResetClick, eventPassThroughObject: { targetId: 'SegmentId'} },
        SegmentIdSelectedItem: { eventType: 'click', eventCallback: clickHandler.ulDropDownClick, eventPassThroughObject: { targetId: 'SegmentId'} },

        _default: {}
    };

})();
